<?php
if ($_POST['edit']!='')
{
$name=$_POST['vname'];
$hash=$_POST['vhash'];
$des=$_POST['vdes'];
$cmd="UPDATE `multivideo` SET video_name='$name',video_hash='$hash',video_descrip='$des' WHERE video_id=".$_GET['edit'];
mysql_query($cmd);
echo 'Sửa thành công Video ';
} else
if ($_POST['add']!='')
{
$name=' ';
$des=' ';
$name.=$_POST['vname'];
$hash=$_POST['vhash'];
$des.=$_POST['vdes'];
$cmd="INSERT INTO `multivideo` VALUES (0,'$name','$hash','$des','_')";
//echo $cmd;
mysql_query($cmd);
echo 'Thêm thành công Video ';
} else
{
if (isset($_GET['act']))
{
echo '<form method="post" enctype="multipart/form-data">
Tên Video <div class="selecttitle"><input type="text" name="vname"></div>
YOUTUBE HASH  <div class="selecttitle"><input type="text" name="vhash"></div>
Mô tả <div class="selecttitle"><input type="text" name="vdes"></div>

<div class="space"></div>
<div class="space"></div>

<input type="submit" class="buttonclick" value="Thêm" name="add"/>
</form>
';
}
else
if (isset($_GET['edit']))
{
$sql="SELECT * FROM `multivideo` WHERE video_id=".$_GET['edit'];
$info=mysql_fetch_assoc(mysql_query($sql));
echo '<form method="post" enctype="multipart/form-data">
Tên Video <div class="selecttitle"><input type="text" name="vname" value="'.$info['video_name'].'"></div>
YOUTUBE HASH  <div class="selecttitle"><input type="text" name="vhash" value="'.$info['video_hash'].'"></div>
Mô tả <div class="selecttitle"><input type="text" name="vdes" value="'.$info['video_descrip'].'"></div>
<div class="space"></div>
<div class="space"></div>
<input type="submit" class="buttonclick" value="Sửa" name="edit"/>
</form>
';			
}
else
{
if (isset($_GET['del']))
{
	$sql="DELETE FROM `multivideo` WHERE video_id=".$_GET['del'];
	mysql_query($sql);
}
if (isset($_GET['x']))
{
	$x=$_GET['x'];
	$decy=$x-15;
	if ($decy<0) $decy=0;
	$incy=$x+15;
} else {$x=0; $decy=0; $incy=15;}
echo '<div id="next"><div class="buttons"><a href="/mem/?menu=channel&x='.$incy.'" class="button">Tiến tới</a></div></div>
<div id="pre"><div class="buttons"><a href="/mem/?menu=channel&x='.$decy.'" class="button">Lùi lại</a></div></div>';
?>
<div id="space"><div class="buttons"><a href="?menu=channel&act=add" class="button add">Thêm</a></div></div>
<div id="search">
<form method="post" action="/mem/?menu=channel&search=keyword">
<input type="text" name="tukhoa" autocomplete="off" class="search" value="Nhập nội dung cần tìm"  onblur="if(this.value=='') this.value='Nhập nội dung cần tìm';" onFocus="if(this.value=='Nhập nội dung cần tìm') this.value='';" />  	 
</form></div>
<?php
echo '
<div id="view">
<table width="775" border="1" class="view" cellpadding="10" cellspacing="0">	
  <th width="30px">ID</th>
  <th width="200px">TÊN VIDEO</th>
  <th>YOUTUBE HASH</th>
  <th width="250px">Mô tả</th>
  <th width="10px">Sửa</th>
  <th width="10px">Xóa</th>';
	if (isset($_GET['search'])) 
	$sql="SELECT * FROM `multivideo` WHERE video_tag LIKE '%".$_POST['tukhoa']."%'";
	else
	$sql='SELECT * FROM `multivideo` ORDER BY  `video_id` DESC LIMIT '.$x.',15';
	  $excute=mysql_query($sql);
	  while ($row=mysql_fetch_array($excute,MYSQL_ASSOC))
	  {
		  echo '<tr><td>'.$row['video_id']; echo '</td>';
		  echo '<td>'.$row['video_name']; echo '</td>';
		  echo '<td>'.$row['video_hash']; echo '</td>';
		  echo '<td>'.$row['video_descrip']; echo '</td>';
		  
echo '<td><div class="buttons"><a class="button flag" href="?menu=channel&edit='.$row['video_id'].'">Sửa</a></div></td>';
echo '<td><div class="buttons"><a class="button delete" href="?menu=channel&del='.$row['video_id'].'">Xóa</a></div></td></tr>';
	  } 
	
	  sql();
echo '</table></div>';
}
}?>


